package com.example.service;

import com.example.entity.Warehouse;
import com.example.mapper.WarehouseMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseService {

    @Resource
    WarehouseMapper warehouseMapper;

    public void add(Warehouse warehouse) {
        warehouseMapper.insert(warehouse);
    }

    public void deleteById(Integer id) {
        warehouseMapper.deleteById(id);
    }

    public void updateById(Warehouse warehouse) {
        warehouseMapper.updateById(warehouse);
    }

    public List<Warehouse> selectAll() {
        return warehouseMapper.selectAll();
    }

    public Warehouse selectById(Integer id) {
        return warehouseMapper.selectById(id);
    }

    public PageInfo<Warehouse> selectPage(Integer pageNum, Integer pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        List<Warehouse> list = warehouseMapper.selectAll();
        return PageInfo.of(list);
    }
}
